package com.lds.employment.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.lds.employment.domain.EmploymentStudent;
import com.lds.employment.service.IEmploymentStudentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 就业学生Controller
 * 
 * @author ruoyi
 * @date 2024-01-05
 */
@RestController
@RequestMapping("/student")
public class EmploymentStudentController extends BaseController
{
    @Autowired
    private IEmploymentStudentService employmentStudentService;

    /**
     * 查询就业学生列表
     */
    @RequiresPermissions("employment:student:list")
    @GetMapping("/list")
    public TableDataInfo list(EmploymentStudent employmentStudent)
    {
        startPage();
        List<EmploymentStudent> list = employmentStudentService.selectEmploymentStudentList(employmentStudent);
        return getDataTable(list);
    }

    /**
     * 导出就业学生列表
     */
    @RequiresPermissions("employment:student:export")
    @Log(title = "就业学生", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmploymentStudent employmentStudent)
    {
        List<EmploymentStudent> list = employmentStudentService.selectEmploymentStudentList(employmentStudent);
        ExcelUtil<EmploymentStudent> util = new ExcelUtil<EmploymentStudent>(EmploymentStudent.class);
        util.exportExcel(response, list, "就业学生数据");
    }

    /**
     * 获取就业学生详细信息
     */
    @RequiresPermissions("employment:student:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(employmentStudentService.selectEmploymentStudentById(id));
    }

    /**
     * 新增就业学生
     */
    @RequiresPermissions("employment:student:add")
    @Log(title = "就业学生", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmploymentStudent employmentStudent)
    {
        return toAjax(employmentStudentService.insertEmploymentStudent(employmentStudent));
    }

    /**
     * 修改就业学生
     */
    @RequiresPermissions("employment:student:edit")
    @Log(title = "就业学生", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmploymentStudent employmentStudent)
    {
        return toAjax(employmentStudentService.updateEmploymentStudent(employmentStudent));
    }

    /**
     * 删除就业学生
     */
    @RequiresPermissions("employment:student:remove")
    @Log(title = "就业学生", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(employmentStudentService.deleteEmploymentStudentByIds(ids));
    }
}
